<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8">
    <title>{% block title %}{% endblock %}</title>
    {% block head_css %}
    <link rel="stylesheet" href="http://labfile.oss.aliyuncs.com/courses/923/week7/code/bootstrap-3.3.7-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="static/main.css">
    {% endblock %}
  </head>
  <body>
    <nav class="navbar navbar-inverse">
      <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/">Simpledu</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li class="active"><a href="/">课程<span class="sr-only">(current)</span></a></li>
            <li><a href="#">直播</a></li>
            {% if current_user.is_authenticated and current_user.is_admin %}
            <li><a href="{{ url_for('admin.index') }}">控制台</a></li>
            {% endif %}
          </ul> 

          <ul class="nav navbar-nav navbar-right">
            {% if not current_user.is_authenticated %}
            <li><a href="{{ url_for('front.register') }}">注册</a></li>
            <li><a href="{{ url_for('front.login') }}">登录</a></li>
            {% else %}
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span id="username">{{ current_user.username }}</span><span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">我的主页</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="{{ url_for('front.logout') }}">退出登录</a></li>
              </ul>
            </li>
            {% endif %}
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav> 

    <div class="container">
      {% with messages = get_flashed_messages(with_categories=true) %}
      {% if messages %}
      {% for category, message in messages %}
      <div class="alert alert-{{ category }} alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        {{ message }}
      </div>
      {% endfor %}
      {% endif %}
      {% endwith %}

      {% block body %}{% endblock %}

      {% block footer %}{% endblock %}
    </div>
    
    {% block tail_js %}
    <script src="http://labfile.oss.aliyuncs.com/courses/923/week7/code/jquery/3.2.1/jquery.min.js"></script>
    <script src="http://labfile.oss.aliyuncs.com/courses/923/week7/code/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script src="static/main.js"></script>
    {% endblock %}
  </body>    
</html>
